package com.e2oto.seller.modules.seller.presenter;

import com.e2oto.seller.common.EasyAES;
import com.e2oto.seller.common.base.BaseBean;
import com.e2oto.seller.common.base.BasePresenter;
import com.e2oto.seller.common.http.ProgressSubscriber;
import com.e2oto.seller.common.http.ProgressSubscriberOnNextListener;
import com.e2oto.seller.common.utils.RetrofitUtils;
import com.e2oto.seller.modules.SellerApp;
import com.e2oto.seller.modules.seller.bean.FirstSystemCategoryBean;
import com.e2oto.seller.modules.seller.bean.SellerTypeBean;
import com.e2oto.seller.modules.seller.views.ShopBaseInfoView;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by ZhangLiQiang on 2017/11/14.
 */

public class ShopBaseInfoPresenter extends BasePresenter<ShopBaseInfoView> {


    /**
     * 商户类型
     *
     * @return
     */
    public void getSellertype() {
        List<SellerTypeBean> types = new ArrayList<>();
        types.add(new SellerTypeBean(0, "个体"));
        types.add(new SellerTypeBean(1, "企业"));
        getView().getSellerTypeCallback(types);
    }

    /**
     * 商户的主营业 系统分类
     *
     * @return
     */
    public void getFirstSystemCategory() {

        RetrofitUtils.getApiService().getSystemFirstCategoryAll(EasyAES.encrypt(), SellerApp.versionName)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ProgressSubscriber(new ProgressSubscriberOnNextListener<FirstSystemCategoryBean>() {
                    @Override
                    public void onNext(FirstSystemCategoryBean o) {
                        getView().getFirstSystemCategoryCallback(o);
                    }
                }, getContext()));


    }

}
